package cn.ldh.oneway_02;

import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

import java.nio.charset.StandardCharsets;

public class producer {


    public static void main(String[] args) throws Exception {

        // 1 创建生产者对象
        DefaultMQProducer producer = new DefaultMQProducer("oneway_group_hello");

        // 2 设置nameServer地址
        producer.setNamesrvAddr("localhost:9876");

        // 3 启动
        producer.start();

        // 4 创建消息
        Message message = new Message("oneway_topic", "hello", "杨庆宫世界第一帅".getBytes(StandardCharsets.UTF_8));

        // 5 因为是单向的所以不需要发送消息 也没有消费者去响应
        producer.sendOneway(message);

        // 关闭
        producer.shutdown();


    }



}
